import { defineStore } from 'pinia'

/**
 * 类似于Vuex，但是要比Vuex更轻量化
 * [官方文档](https://pinia.vuejs.org/introduction.html)
 */
export const useStore = defineStore('test', {
	state: () => ({
		name: '超级管理员',
	}),
	getters: {
		nameLength: (state) => state.name.length,
	},
	actions: {
		insertPost(data) {
			// 可以做异步
			// setTimeout(() => {}, 0)
			this.name = data
		},
	},
})
